package xiao_jin.fantastic_journey.client.mixin;

import club.someoneice.cookie.event.EventBus;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.render.RenderTickCounter;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import xiao_jin.fantastic_journey.core.handler.RenderTickEvent;

@Environment(EnvType.CLIENT)
@Mixin(RenderTickCounter.Dynamic.class)
public class ClientRenderTickHook {
    @Inject(method = "beginRenderTick(J)I", at = @At("RETURN"))
    public void onRenderTick(long timeMillis, CallbackInfoReturnable<Integer> cir) {
        EventBus.post(new RenderTickEvent(cir.getReturnValue()));
    }
}
